package com.chuyu.jzwboa.adapter.message;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.chuyu.jzwboa.R;

import java.util.List;

/**
 * @author 杨仕俊
 * @description 消息 聊天fragment adaper
 * Created by wo on 2017/12/15.
 */

public class ChatAdapter extends BaseAdapter {
    private Context context;
    private List<String> list;

    public ChatAdapter(Context context, List<String> liststr) {
        this.context = context;
        this.list = liststr;
    }

    @Override
    public int getCount() {
        return list==null?0:list.size();
    }

    @Override
    public Object getItem(int i) {
        return null;
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewHolder holder;
        if (view==null){
            holder = new ViewHolder();
            view=View.inflate(context, R.layout.item_chat,null);
            holder.time=view.findViewById(R.id.text_chat_time);
            holder.content=view.findViewById(R.id.text_chat_content);
            holder.name=view.findViewById(R.id.text_chat_name);
            holder.tvChatNo=view.findViewById(R.id.tv_chat_no);
            holder.ivChat=view.findViewById(R.id.iv_chat);
            view.setTag(holder);
        }else {
            holder= (ViewHolder) view.getTag();
        }

        return view;
    }

    class ViewHolder {
        TextView tvChatNo;
        ImageView ivChat;
        TextView content;
        TextView time;
        TextView name;

    }
}
